<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>e网批发管理后台</title>
  <?php include("common/conn.php"); if($_SESSION['userid']==""){echo "<script>window.location.href='login.php';</script>";} 

  if($_GET['del']=="ok")
  {
    $area = array(); 
    $area= $_POST['checkbox'];
    foreach ($area as $k=>$v)
    {
      $srat1=mysql_query("DELETE FROM talks where id='".$v."'");
    }

  }

  if($_REQUEST['jing']=="ok")
  {
    $i=1;
    $srat1=mysql_query("update talks set state='".$i."' where id='".$_REQUEST['id']."'");
  }
  ?>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <link href="css/styles.css" rel="stylesheet" type="text/css" />
  <link href="css/style2.css" rel="stylesheet" type="text/css" />
  <script type="text/JavaScript">
    <!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->


  <!-- staqrt subnav -->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">

      <!-- start sub nav list -->
      <div id="subnav" class=" grid_12">
        <ul>
          <li> <a href="dongtai.php?path=1" <?php if ($_GET[path]==1) {echo "class='sub_nav_active'";} ?>> 跳骚市场 </a></li>
          <li> <a href="dongtai.php?path=2" <?php if ($_GET[path]==2) {echo "class='sub_nav_active'";} ?>> 尾货市场 </a></li>
          <li> <a href="dongtai.php?path=3" <?php if ($_GET[path]==3) {echo "class='sub_nav_active'";} ?>> 商圈聊 </a></li>
        </ul>

      </div>
      <!-- end subnavigation list -->	

    </div>
  </div>
  <div class="container_12">


    <label>市场</label>
    <select name="classify" class="select" onchange="MM_jumpMenu('parent',this,0)">
      <?php if (!isset($_GET[cityid])) {?>
      <option value="?path=<?php echo $_GET[path]; ?>">全部市场</option>
      <?php }?>

      <?php if($_GET[city]!=""){?>
      <option value="?path=<?php echo $_GET[path]; ?>">全部市场</option>
      <?php }else{?>
      <?php } $rert32=mysql_query("select * from city order by id desc ");
      while($sdg32=mysql_fetch_array($rert32)){?>
      <option  value="?city=<?php echo $sdg32[city];?>&cityid=<?php echo $sdg32[id];?>&path=<?php echo $_GET[path];?>" <?php if ($sdg32[id]==$_REQUEST[cityid]) { ?>selected<?php } ?>><?php echo $sdg32[city];?></option>
      <?php }?>

    </select>
    <form action="?path=<?php echo $_GET[path]; ?>" method="post" style="display:inline-block;">
      <input  type="text"  class="text" placeholder="搜索市场关键字"  name="keywords"/>
      <input name="" type="submit" value="搜索动态" class="submit"/>
    </form>
  </div>

  <div class="container_12">
    <!-- end sub_nav -->
    <form action="?del=ok&path=<?php echo $_GET[path]; ?>" method="post" id="form">
      <!-- EVERYTING BELOW IS THE MAIN CONTENT -->
<!--       <table width="100%" border="1">
        <tr>
          <td><input type="checkbox" name="checkbox" id="checkbox" class="checkall" /><label for="checkbox"></label></td>
        </tr>
      </table> -->




      <?php 


      $sex="0";
$perNumber=20; //每页显示的记录数
$page=$_GET['page']; //获得当前的页面值
if($_REQUEST[keywords]!="")
{
  $count=mysql_query("select count(*) from talks where title like '".$_REQUEST[keywords]."%' and path='".$_GET[path]."'");

}else if($_REQUEST[cityid]!=""){

  $count=mysql_query("select count(*) from talks where cityid = '".$_REQUEST[cityid]."'and  path='".$_GET[path]."'");
}else if($_REQUEST[id]!=""){
  $count=mysql_query("select count(*) from talks where cyclassify = '".$_REQUEST[id]."' and path='".$_GET[path]."'");

}
else
{
  $count=mysql_query("select count(*) from talks where path='".$_GET[path]."'");
}

//获得记录总数
$rs=mysql_fetch_array($count);
$totalNumber=$rs[0];
$totalPage=ceil($totalNumber/$perNumber); //计算出总页数

if (!isset($page)) {
  $page=1;
} //如果没有值,则赋值1
$startCount=($page-1)*$perNumber; //分页开始,根据此方法计算出开始的

if($_REQUEST[keywords]!="")
{
  $rert30=mysql_query("select * from talks where title like '".$_REQUEST[keywords]."%' and path='".$_GET[path]."' order by id desc limit $startCount,$perNumber");
}

else if($_REQUEST[id]!="")
{
  $rert30=mysql_query("select * from talks where cyclassify = '".$_REQUEST[id]."' order and path='".$_GET[path]."' by id desc limit $startCount,$perNumber");
}else if($_REQUEST[cityid]!=""){

  $rert30=mysql_query("select * from talks where  cityid = '".$_REQUEST[cityid]."'and  path='".$_GET[path]."'  order by id desc limit $startCount,$perNumber");

}else {
  $rert30=mysql_query("select * from talks where path='".$_GET[path]."'  order by id desc limit $startCount,$perNumber");
}	
while($sdg=mysql_fetch_array($rert30))
{
  $rert2=mysql_query("select * from user where  userid='".$sdg['userid']."' "); 
  $user=mysql_fetch_array($rert2);

  $count3=mysql_query("select count(*) from reply where talkid='".$sdg['id']."' ");

//获得记录总数
  $rs3=mysql_fetch_array($count3); 
  $total4=$rs3[0];

  ?>
  <div class="cy_mode">
    <div class="cy_mimgs">
      <input type="checkbox" name="checkbox[]" id="checkbox"  value="<?php echo $sdg[id];?>"/>
      <!-- <?php if($sdg["state"]=="1"){echo "<img src='images/wet.png'/>";}else{?><a href="?jing=ok&id=<?php echo $sdg[id];?>">设为精华</a><?php }?> -->
    </div>
<!-- 	     <div class="cy_mimg"><a href="userfile2.php?id=<?php echo $sdg[id]; ?>">
<img src="<?php if($user[images]!=""){echo $user[images];}else{ echo "images/women.jpg";} ?>" width="100%" height="100%"></a>
</div> -->
<div class="cy_mcon">
  <span style="color:gray;">标题:</span><span style="color:red"><?php echo $sdg[title]; ?></span>
  &nbsp;&nbsp;&nbsp;
  <span style="color:gray;">发帖人:</span><span style="color:#E91D55"><?php echo $user[niname]; ?>
</span><br/>
<?php  $ime=$sdg[images];
$de=explode("," ,$ime);
if ($de[0]!='') {
  ?>
  <a href="userfile2.php?id=<?php echo $sdg[id]; ?>&path=<?php echo $_GET[path]; ?>">	 
    <img src="<?php echo $de[0];?>" width="20%"> 
  </a>
  <?php  } ?>
  <br/><a href="userfile2.php?id=<?php echo $sdg[id]; ?>&path=<?php echo $_GET[path]; ?>">

  <span class="all_fr conf_wd"><?php $time1 = strtotime($sdg[addtime]);
    $time2 = strtotime(now);
    $second = $time2 - $time1;
    $day = floor($second/(3600*24));    
    $hour = floor($second/3600);
    $minute = floor($second/60); if($minute<60){ echo $minute,"分钟前"; } else if($hour<24 and $hour>=1) { echo $hour,"小时前"; }else if($day<3 and $day>=1) { echo $day,"天前"; }else{ echo $sdg[addtime];}?>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:red;">回复数:</span><span class="conf-r"><?php echo $total4;?></span></span>
  </a></div>

</div>

<?php } ?>
</form>

<!-- END TABULAR DATA EXAMPLE -->



<div class="grid_12">

  <div class="clearfix"><input  type="button"  value="删除选中" class="submit del"/></div>



  <ul id="pagination">
    <?php  

    if ($page > 1) { //上一页 ?>
    <li><a     href="?page=1&state=<?php echo $_REQUEST[state]; ?>">首页</a></li>
    <li><a     href="?page=<?php echo ($page-1); ?>&state=<?php echo $_REQUEST[state]; ?>">上一页</a></li>
    <?php }?>

    <li class="active"><?php echo $page;?></li>

    <?php



    if ($_GET[page]!=$totalPage) { //下一页 ?>
    <li><a     href="?page=<?php echo ($page+1); ?>&state=<?php echo $_REQUEST[state]; ?>">下一页</a></li>
    <?php }

    if ($totalPage>1) { //下一页 ?>
    <li><a     href="?page=<?php echo $totalPage; ?>&state=<?php echo $_REQUEST[state]; ?>">尾页</a></li>

    <?php }?>
    <input type="text" class="text skip_val" style="width: 20px;height:12px;margin:0 5px;"><button class="submit skip">跳转</button>
    总共有<?php echo $totalNumber;?>结果 

  </ul>
</div>           







</div>

<!-- end content wrap -->


</div>
</body>
<script type="text/javascript">
  // 删除 
  $('.del').click(function(){
    $('#form').submit();
  })
  // 删除 end

  // 页面跳转 
  $('.skip').click(function(){
    var page = $('.skip_val').val();
    var url = "dongtai.php?page="+page;
    window.location.href = url;
  })
  // 页面跳转 end
</script>
</html>
